package com.zqg8512.server.sqlite.test.web;

import com.zqg8512.server.sqlite.test.model.Hello;
import com.zqg8512.server.sqlite.test.server.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zengqianggang
 * @Description //TODO
 * Author VPN
 * @Date 2019/9/5 17:22
 * @Version 1.0
 **/
@RequestMapping("/sqlit/test")
@RestController
public class HelloController {

    @Autowired
    HelloService helloService;

    @RequestMapping(value = "/hello", method = {RequestMethod.GET})
    public List<Hello> getHellos(){
        return helloService.selectAll();
    }

    @RequestMapping(value = "/hello/{id}", method = {RequestMethod.GET})
    public Hello getHello(@PathVariable Integer id){
        return helloService.select(id);
    }

    @RequestMapping(value = "/hello",method = {RequestMethod.DELETE})
    public boolean delete(Integer id){
        return helloService.delete(id);
    }

    @RequestMapping(value = "/hello",method = {RequestMethod.POST})
    public boolean delete(Hello hello){
        return helloService.insert(hello);
    }

}
